package com.yellowcong;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;

import com.yellowcong.filter.EncoderFilter;
import com.yellowcong.filter.PageFilter;

@SpringBootApplication
public class ConfigMain {  
	  
	/**
	 * 使用代码注册Servlet（不需要@ServletComponentScan注解）
	 * @return
	 */
	@Bean  
    public FilterRegistrationBean filterPageRegistration() {  
        FilterRegistrationBean registration = new FilterRegistrationBean();  
        registration.setFilter(new PageFilter());
        //设定匹配的路径
        registration.addUrlPatterns("/*");
        //添加初始化的参数
        registration.addInitParameter("pageSize", "100");
        registration.addInitParameter("pageOrder", "desc");
        //设定名称
        registration.setName("encodeFilter");
        //设定加载的顺序
        registration.setOrder(2);  
        return registration;  
    }
	
	/**
	 * 
	 * @return
	 */
	@Bean  
    public FilterRegistrationBean filterCodeRegistration() {  
        FilterRegistrationBean registration = new FilterRegistrationBean();  
        registration.setFilter(new EncoderFilter());
        //设定匹配的路径
        registration.addUrlPatterns("/*");
        //设定加载的顺序
        registration.setOrder(2);  
        return registration;  
    }
	
    public static void main(String[] args) {  
        SpringApplication.run(ConfigMain.class, args);  
    }  
}
